#!/usr/bin/perl 
use DBI;
use CGI;
# use TTrakerSite;
use TTraker;

my $form_ref = &parse_input;
& print_header;
& initialize_dbi;

my %FORM_DATA = %$form_ref; 
my $num = $FORM_DATA{'empNum'};
my $name = $FORM_DATA{'empName'};
my $job = $FORM_DATA{'empJob'};
my $loc = $FORM_DATA{'empLoc'};
my $cli = $FORM_DATA{'cliID'};

my @tasks = ();
$task_count = get_adm_task_count ($cli);
if ( $task_count == 0 ) {
   $message = "NO TASKS AVAILABLE FOR $cli! Check with administrator.";
   sup_activity_selection_message;
} else {
   $task_ref = get_adm_task_list ($cli);  
   @tasks = @$task_ref;
#   print "adm_adjust_client_std_time COMING UP<br/>";
   &screen_adm_adjust_client_std_time;
}

db_disconnect();

##################### SUBROUTINES FOLLOW  #####################

sub screen_adm_adjust_client_std_time
{
#   print "adm_adjust_client_std_time WERE IN!<br/>";

  print <<ENDHEADER;
  <html>
  <head>
  <link rel='stylesheet' type='text/css' href='${css_ref}trak.css' />
  <script type='text/javascript' src='${js_ref}trak.js'></script>
  <title>trak_03_adm_adjust_std_time.pl</title>
  </head>
  <body>
  <h2><center>${banner}</center></h2>
  <hr/>
  <div id='box5_1'>
  <h3>Adjust Standard Time for $cli Tasks</h3>
  <form onkeypress='return event.keyCode != 13;' autocomplete='off'  name='activity' action='${cgi_ref}trak_04_adm_adjust_std_time.pl' method='post'>
  <input type="hidden" name=empNum value='$num'/>
  <input type="hidden" name=empName value='$name'/>
  <input type="hidden" name=empJob value='$job'/>
  <input type="hidden" name=empLoc value='$loc'/>
  <input type="hidden" name="cliID" value='$cli'/>
  <table>
    <tr>
      <th>Code</th>
      <th>Description</th>
      <th>Units</th>
      <th>Std Time</th>
      <th>&nbsp&nbsp&nbsp</th>
      <th>New Std</th>
      <th>&nbsp&nbsp&nbsp</th>
      <th>Rate</th>
      <th>&nbsp&nbsp&nbsp</th>
      <th>New Rate</th>
    </tr>
ENDHEADER
 # print "THERE ARE $#tasks TASKS!<br/>"; 
 for $i (0..$#tasks ) {
   my $cli = $tasks[$i][0];
   my $code = $tasks[$i][1];
   my $desc = $tasks[$i][2];
   my $units = $tasks[$i][3];
   my $curStd = $tasks[$i][4];
   my $curRate = $tasks[$i][5];
   
   print <<ENDHEADER;
   <tr>
     <td>&nbsp&nbsp&nbsp $code</td>
     <td>&nbsp&nbsp&nbsp $desc</td>
     <td>&nbsp&nbsp&nbsp $units</td>
     <td>&nbsp&nbsp&nbsp $curStd</td>
     <td>&nbsp&nbsp&nbsp</td>
     <td><input type='text' size='6' name='new_std_${code}'/></td>
     <td>&nbsp&nbsp&nbsp</td>
     <td>&nbsp&nbsp&nbsp $curRate</td>
     <td>&nbsp&nbsp&nbsp</td>
     <td><input type='text' size='6' name='new_rate_${code}'/></td>
   </tr>
ENDHEADER
 }
 print <<ENDHEADER;
 </table>
 <br/><br/>
 <input type='submit' value='Adjust Standard Time/Rate'>
 <br/><br/>
 <p><a href="${cgi_ref}trak_00_adm_activity.pl?num=$num&name=$name&job=$job&loc=$loc">Return to Activities</a></p>
 </form>
 </body>
 </html>
ENDHEADER
}
